"""
请使用 pip 安装 DrissionPage：

pip install DrissionPage
"""

# 导入
from DrissionPage import ChromiumPage, ChromiumOptions, SessionPage
import sys

co = ChromiumOptions()

# 设置启动时最大化
co.set_argument('--start-maximized')


def get_goods_info(bar_code):
    # 创建对象
    page = ChromiumPage()

    page.set.load_mode.none()

    url = "https://www.gds.org.cn/#/home/index"

    page.get(url)

    page.wait.load_start()

    items = page.ele("@placeholder=请输入商品条码").input(bar_code)

    page.ele("@class=el-button searchBtn el-button--primary").click()

    page.wait.load_start()

    page.ele("产品档案信息：").click()

    page.wait.load_start()

    table = page.ele("@class=product_content")

    page.quit()


if __name__ == '__main__':
    # bar_code = sys.argv[1]
    bar_code = "6927462215862"

    get_goods_info(bar_code)

    # if len(bar_code) > 0:
    #    get_goods_info(bar_code)
    # else:
    #    print("请输入商品条码")
